#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int n;
int a[N], b[N], c[N], d[N];
int x, y;
int find()
{
    for (int i = n; i >= 1; i--)
    {
        if (x >= a[i] && x <= a[i] + c[i] && y >= b[i] && y <= b[i] + d[i])
        {
            return i;
        }
    }
    return -1;
}
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    cin >> x >> y;
    cout << find();
    return 0;
}